home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / LiveFastStartServer / Open Transport 1.3 / Includes / CIncludes / stropts.h < prev   
Encoding:
C/C++ Source or Header  |  1998-04-30  |  9.0 KB  |  239 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        stropts.h
  3.  
  4.     Copyright:    © 1991-1996 by Mentat Inc., all rights reserved.
  5.  
  6. */
  7.  
  8. #ifndef __STROPTS__
  9. #define __STROPTS__
  10.  
  11. #ifndef __OPENTRANSPORT__
  12. #include <OpenTransport.h>
  13. #endif
  14.  
  15. #if PRAGMA_ALIGN_SUPPORTED
  16. #pragma options align=mac68k
  17. #endif
  18. #if PRAGMA_IMPORT_SUPPORTED
  19. #pragma import on
  20. #endif
  21.  
  22. #define I_NREAD         MIOC_CMD(MIOC_STREAMIO,1)        /* return the number of bytes in 1st msg */
  23. #define I_PUSH            MIOC_CMD(MIOC_STREAMIO,2)        /* push module just below stream head */
  24. #define I_POP            MIOC_CMD(MIOC_STREAMIO,3)        /* pop module below stream head */
  25. #define I_LOOK            MIOC_CMD(MIOC_STREAMIO,4)        /* retrieve name of first stream module */
  26. #define I_FLUSH         MIOC_CMD(MIOC_STREAMIO,5)        /* flush all input and/or output queues */
  27. #define I_SRDOPT        MIOC_CMD(MIOC_STREAMIO,6)        /* set the read mode */
  28. #define I_GRDOPT        MIOC_CMD(MIOC_STREAMIO,7)        /* get the current read mode */
  29. #define    I_STR            MIOC_CMD(MIOC_STREAMIO,8)        /* create an internal ioctl message            */
  30. #define I_SETSIG        MIOC_CMD(MIOC_STREAMIO,9)        /* request SIGPOLL signal on events */
  31. #define I_GETSIG        MIOC_CMD(MIOC_STREAMIO,10)        /* query the registered events */
  32. #define    I_FIND            MIOC_CMD(MIOC_STREAMIO,11)        /* check for module in stream                */
  33. #define I_LINK            MIOC_CMD(MIOC_STREAMIO,12)        /* connect stream under mux fd */
  34. #define I_UNLINK        MIOC_CMD(MIOC_STREAMIO,13)        /* disconnect two streams */
  35. #define I_PEEK            MIOC_CMD(MIOC_STREAMIO,15)        /* peek at data on read queue */
  36. #define I_FDINSERT        MIOC_CMD(MIOC_STREAMIO,16)        /* create a message and send downstream */
  37. #define I_SENDFD        MIOC_CMD(MIOC_STREAMIO,17)        /* send an fd to a connected pipe stream */
  38. #define I_RECVFD        MIOC_CMD(MIOC_STREAMIO,18)        /* retrieve a file descriptor */
  39. #define I_FLUSHBAND     MIOC_CMD(MIOC_STREAMIO,19)        /* flush a particular input and/or output band */
  40. #define I_SWROPT        MIOC_CMD(MIOC_STREAMIO,20)        /* set the write mode */
  41. #define I_GWROPT        MIOC_CMD(MIOC_STREAMIO,21)        /* get the current write mode */
  42. #define I_LIST            MIOC_CMD(MIOC_STREAMIO,22)        /* get a list of all modules on a stream    */
  43. #define I_ATMARK        MIOC_CMD(MIOC_STREAMIO,23)        /* check to see if the next message is "marked" */
  44. #define I_CKBAND        MIOC_CMD(MIOC_STREAMIO,24)        /* check for a message of a particular band */
  45. #define I_GETBAND        MIOC_CMD(MIOC_STREAMIO,25)        /* get the band of the next message to be read */
  46. #define I_CANPUT        MIOC_CMD(MIOC_STREAMIO,26)        /* check to see if a message may be passed on a stream */
  47. #define I_SETCLTIME     MIOC_CMD(MIOC_STREAMIO,27)        /* set the close timeout wait */
  48. #define I_GETCLTIME     MIOC_CMD(MIOC_STREAMIO,28)        /* get the current close timeout wait */
  49. #define I_PLINK         MIOC_CMD(MIOC_STREAMIO,29)        /* permanently connect a stream under a mux */
  50. #define I_PUNLINK        MIOC_CMD(MIOC_STREAMIO,30)        /* disconnect a permanent link */
  51.  
  52. /* ioctl values needed on non-SYS V systems */
  53. #define I_GETMSG        MIOC_CMD(MIOC_STREAMIO,40)        /* getmsg() system call */
  54. #define I_PUTMSG        MIOC_CMD(MIOC_STREAMIO,41)        /* putmsg() system call */
  55. #define I_POLL            MIOC_CMD(MIOC_STREAMIO,42)        /* poll() system call */
  56. #define I_SETDELAY        MIOC_CMD(MIOC_STREAMIO,43)        /* set blocking status */
  57. #define I_GETDELAY        MIOC_CMD(MIOC_STREAMIO,44)        /* get blocking status */
  58. #define I_RUN_QUEUES    MIOC_CMD(MIOC_STREAMIO,45)        /* sacrifice for the greater good */
  59. #define I_GETPMSG        MIOC_CMD(MIOC_STREAMIO,46)        /* getpmsg() system call */
  60. #define I_PUTPMSG        MIOC_CMD(MIOC_STREAMIO,47)        /* putpmsg() system call */
  61. #define I_AUTOPUSH        MIOC_CMD(MIOC_STREAMIO,48)        /* for systems that cannot do the autopush in open */
  62. #define I_PIPE            MIOC_CMD(MIOC_STREAMIO,49)        /* for pipe library call */
  63. #define I_HEAP_REPORT    MIOC_CMD(MIOC_STREAMIO,50)        /* get heap statistics */
  64. #define    I_FIFO            MIOC_CMD(MIOC_STREAMIO,51)        /* for fifo library call */
  65.  
  66. /* priority message request on putmsg() or strpeek */
  67. #define RS_HIPRI        0x1
  68.  
  69. /* flags for getpmsg and putpmsg */
  70. #define MSG_HIPRI        RS_HIPRI
  71. #define MSG_BAND        0x2             /* Retrieve a message from a particular band */
  72. #define MSG_ANY         0x4             /* Retrieve a message from any band */
  73.  
  74. /* return values from getmsg(), 0 indicates all ok */
  75. #define MORECTL         0x1     /* more control info available */
  76. #define MOREDATA        0x2     /* more data available */
  77.  
  78. #ifndef FMNAMESZ
  79. #define FMNAMESZ        31    /* maximum length of a module or device name */
  80. #endif
  81.  
  82. /* Infinite poll wait time */
  83. #define INFTIM            -1
  84.  
  85. /* flush requests */
  86. #define FLUSHR            0x1             /* Flush the read queue */
  87. #define FLUSHW            0x2             /* Flush the write queue */
  88. #define FLUSHRW         (FLUSHW|FLUSHR) /* Flush both */
  89. #define FLUSHBAND        0x40            /* Flush a particular band */
  90.  
  91. /* I_FLUSHBAND */
  92. struct bandinfo 
  93. {
  94.     unsigned char    bi_pri;         /* Band to flush */
  95.     int_t             bi_flag;        /* One of the above flush requests */
  96. };
  97.  
  98. /* flags for I_ATMARK */
  99. #define ANYMARK         0x1             /* Check if message is marked */
  100. #define LASTMARK        0x2             /* Check if this is the only message marked */
  101.  
  102. /* signal event masks */
  103. #define S_INPUT         0x1     /* A non-M_PCPROTO message has arrived */
  104. #define S_HIPRI         0x2     /* A priority (M_PCPROTO) message is available */
  105. #define S_OUTPUT        0x4     /* The write queue is no longer full */
  106. #define S_MSG            0x8     /* A signal message has reached the front of read queue */
  107. #define S_RDNORM        0x10    /* A non-priority message is available */
  108. #define S_RDBAND        0x20    /* A banded messsage is available */
  109. #define S_WRNORM        0x40    /* Same as S_OUTPUT */
  110. #define S_WRBAND        0x80    /* A priority band exists and is writable */
  111. #define S_ERROR         0x100    /* Error message has arrived */
  112. #define S_HANGUP        0x200    /* Hangup message has arrived */
  113. #define S_BANDURG        0x400    /* Use SIGURG instead of SIGPOLL on S_RDBAND signals */
  114.  
  115. /* read mode bits for I_S|GRDOPT; choose one of the following */
  116. #define RNORM            0x01    /* byte-stream mode, default */
  117. #define RMSGD            0x02    /* message-discard mode */
  118. #define RMSGN            0x04    /* message-nondiscard mode */
  119. #define RFILL            0x08    /* fill read buffer mode (PSE private) */
  120.  
  121. /* More read modes, these are bitwise or'ed with the modes above */
  122. #define RPROTNORM        0x10    /* Normal handling of M_PROTO/M_PCPROTO messages, default */
  123. #define RPROTDIS        0x20    /* Discard M_PROTO/M_PCPROTO message blocks */
  124. #define RPROTDAT        0x40    /* Convert M_PROTO/M_PCPROTO message blocks into M_DATA */
  125.  
  126. /* write modes for I_S|GWROPT */
  127. #define SNDZERO         0x1     /* Send a zero-length message downstream on a write of zero bytes */
  128.  
  129. #define MUXID_ALL        -1        /* Unlink all lower streams for I_UNLINK and I_PUNLINK */
  130.  
  131. struct strbuf 
  132. {
  133.     int_t     maxlen;         /* max buffer length */
  134.     int_t     len;            /* length of data */
  135.     char*    buf;            /* pointer to buffer */
  136. };
  137.  
  138. /* structure of ioctl data on I_FDINSERT */
  139. struct strfdinsert 
  140. {
  141.     struct strbuf    ctlbuf;
  142.     struct strbuf    databuf;
  143.     long            flags;    /* type of message, 0 or RS_HIPRI */
  144.     long            fildes; /* fd of other stream (FDCELL) */
  145.     int_t             offset; /* where to put other stream read qp */
  146. };
  147.  
  148. /* I_LIST structures */
  149. struct str_list 
  150. {
  151.     int_t     sl_nmods;                /* number of modules in sl_modlist array */
  152.     struct str_mlist* sl_modlist;
  153. };
  154.  
  155. struct str_mlist 
  156. {
  157.     char    l_name[FMNAMESZ + 1];
  158. };
  159.  
  160. /* I_PEEK structure */
  161. struct strpeek 
  162. {
  163.     struct strbuf    ctlbuf;
  164.     struct strbuf    databuf;
  165.     long            flags;    /* if RS_HIPRI, get priority messages only */
  166. };
  167.  
  168. struct strpmsg                 /* structure for getpmsg and putpmsg */
  169. {
  170.     struct strbuf    ctlbuf;
  171.     struct strbuf    databuf;
  172.     int_t             band;
  173.     long            flags;
  174. };
  175.  
  176. /* structure of ioctl data on I_RECVFD */
  177. struct strrecvfd 
  178. {
  179.     long            fd;     /* new file descriptor (FDCELL) */
  180.     unsigned short    uid;    /* user id of sending stream */
  181.     unsigned short    gid;
  182.     char            fill[8];
  183. };
  184.  
  185. /* structure of ioctl data on I_STR */
  186. struct strioctl 
  187. {
  188.     int_t     ic_cmd;         /* downstream command */
  189.     int_t     ic_timout;        /* ACK/NAK timeout */
  190.     int_t     ic_len;         /* length of data arg */
  191.     char*    ic_dp;        /* ptr to data arg */
  192. };
  193.  
  194. #if !OTKERNEL
  195.  
  196. #ifdef __cplusplus
  197. extern "C" {
  198. #endif
  199.  
  200. pascal    int getmsg(int fd, struct strbuf* ctlbuf, struct strbuf* databuf, int* flagsp);
  201. pascal    int putmsg(int fd, const struct strbuf* ctlbuf, const struct strbuf* databuf, int flags);
  202. pascal    int getpmsg(int fd, struct strbuf* ctlbuf, struct strbuf* databuf, int* bandp, int* flagsp);
  203. pascal    int putpmsg(int fd, const struct strbuf* ctlbuf, const struct strbuf* databuf, int band, int flags);
  204. //
  205. // These are here for compatibility with the rest of xti, but are not the preferred interfaces.
  206. //
  207. #ifdef __OPENTRANSPORT__
  208. pascal int    stream_installnotifier(int fd, OTNotifyProcPtr, void* contextPtr);
  209. pascal int    stream_blocking(int fd);
  210. pascal int    stream_nonblocking(int fd);
  211. pascal int    stream_isblocking(int fd);
  212. pascal int    stream_synchronous(int fd);
  213. pascal int    stream_asynchronous(int fd);
  214. pascal int    stream_issynchronous(int fd);
  215. #endif
  216. pascal int    stream_open(char* path, unsigned long);
  217. pascal int    stream_close(int fd);
  218. pascal int    stream_read(int fd, void* buf, size_t len);
  219. pascal int    stream_write(int fd, void* buf, size_t len);
  220.        int    stream_ioctl(int fd, unsigned long type, ...);
  221. pascal int    stream_pipe(int*);
  222. pascal int    poll(struct pollfd* fds, size_t nfds, unsigned long timeout);
  223.  
  224. #ifdef __cplusplus
  225. }
  226. #endif
  227.  
  228. #endif /* OTKERNEL */
  229.  
  230. #if PRAGMA_ALIGN_SUPPORTED
  231. #pragma options align=reset
  232. #endif
  233. #if PRAGMA_IMPORT_SUPPORTED
  234. #pragma import off
  235. #endif
  236.  
  237. #endif    /* ifdef _STROPTS_ */
  238.  
  239.